<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Called when applying the filter</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.php-user-filter.html">« php_user_filter</a></li>
      <li style="float: right;"><a href="php-user-filter.onclose.html">php_user_filter::onClose »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.php-user-filter.html">php_user_filter</a></li>
    <li>Called when applying the filter</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="php-user-filter.filter" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">php_user_filter::filter</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">php_user_filter::filter</span> &mdash; <span class="dc-title">Called when applying the filter</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-php-user-filter.filter-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>php_user_filter::filter</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">resource</span> <code class="parameter">$in</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">resource</span> <code class="parameter">$out</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$consumed</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">bool</span> <code class="parameter">$closing</code></span><br>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   This method is called whenever data is read from or written to
   the attached stream (such as with <span class="function"><a href="function.fread.html" class="function">fread()</a></span> or <span class="function"><a href="function.fwrite.html" class="function">fwrite()</a></span>).
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-php-user-filter.filter-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">in</code></dt>

    <dd>

     <p class="para">
      <code class="parameter">in</code> is a resource pointing to a <code class="literal">bucket brigade</code>
      which contains one or more <code class="literal">bucket</code> objects containing data to be filtered.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">out</code></dt>

    <dd>

     <p class="para">
      <code class="parameter">out</code> is a resource pointing to a second <code class="literal">bucket brigade</code>
      into which your modified buckets should be placed.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">consumed</code></dt>

    <dd>

     <p class="para">
      <code class="parameter">consumed</code>, which must <em class="emphasis">always</em>
      be declared by reference, should be incremented by the length of the data
      which your filter reads in and alters.  In most cases this means you will
      increment <code class="parameter">consumed</code> by <code class="literal">$bucket-&gt;datalen</code>
      for each <code class="literal">$bucket</code>.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">closing</code></dt>

    <dd>

     <p class="para">
      If the stream is in the process of closing
      (and therefore this is the last pass through the filterchain),
      the <code class="parameter">closing</code> parameter will be set to <strong><code>true</code></strong>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-php-user-filter.filter-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The <span class="methodname"><strong>filter()</strong></span> method must return one of
   three values upon completion.
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Return Value</th>
       <th>Meaning</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><strong><code>PSFS_PASS_ON</code></strong></td>
       <td>
        Filter processed successfully with data available in the
        <code class="parameter">out</code> <code class="literal">bucket brigade</code>.
       </td>
      </tr>

      <tr>
       <td><strong><code>PSFS_FEED_ME</code></strong></td>
       <td>
        Filter processed successfully, however no data was available to
        return. More data is required from the stream or prior filter.
       </td>
      </tr>

      <tr>
       <td><strong><code>PSFS_ERR_FATAL</code></strong> (default)</td>
       <td>
        The filter experienced an unrecoverable error and cannot continue.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>



</div></div></div></body></html>